package com.aistar.user.mapper;

import com.aistar.user.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;



/**
 * Created by js on 2019/6/22.
 */
public interface UserMapper {

    //注册用户
    @Insert("insert into user values(#{id},#{username},#{realname},#{gender},#{birthday},#{phone},#{email},#{address},#{password},#{number},#{headurl})")
    void save(User user);

    //根据id查询用户
    @Select("select * from user where id=#{id}")
    User findById(String id);

    //根据用户名登录
    @Select("select * from user where username=#{username}")
    User findByUsername(String username);

    //根据电话号码登录
    @Select("select * from user where phone=#{phone}")
    User findByPhone(String phone);

    //根据邮箱登录
    @Select("select * from user where email=#{email}")
    User findByEmail(String email);


    //登录
    @Select("select * from user where username=#{username} or phone=#{phone} or email=#{email}")
    User findUser(User user);

    //更新用户信息
    @Update("update user set username=#{username},birthday=#{birthday},email=#{email},phone=#{phone},address=#{address},gender=#{gender},headurl=#{headurl} where id=#{id}")
    void update(User user);

    //更改密码
    @Update("update user set username=#{username},birthday=#{birthday},email=#{email},phone=#{phone},address=#{address},gender=#{gender},headurl=#{headurl},password=#{password} where id=#{id}")
    void updatePassword(User user);



}
